package all.com.jinyongqunxiax.component;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import all.com.jinyongqunxiax.R;

public class JxFormItemText extends JxForm.AbstractItemViewModel {
    JxForm.TextField field;

    public JxFormItemText(int level, JxForm.TextField field, JxForm.OnClickListener removeButtonListener) {
        super(R.layout.jxform_text_item, level, removeButtonListener);
        this.field = field;
    }

    @Override
    void bind(View view) {
        TextView textView = view.findViewById(R.id.form_header_titleView);
        if (textView != null) {
            textView.setText(this.field.label);
            bindLabel(view.getContext(), textView, field);
        }
        EditText editText = view.findViewById(R.id.form_header_valueEditText);

        if (editText != null) {
            editText.setHint(this.field.hint);
            editText.setText(this.field.value);
            bindValue(view.getContext(), editText, field);
        }
    }

    @Override
    int removeButtonID() {
        return R.id.form_item_delete;
    }

    @Override
    int intentViewID() {
        return R.id.form_header_guide_line;
    }
}
